#ifndef _SEARCHSORTHANDLER_H_
#define _SEARCHSORTHANDLER_H_

/*
 * =====================================================================================
 *
 *       Filename:  searchSortHandler.h    
 *        
 *
 *         Author:  Alvin Chan (A0097379H), chanwh.alvin@gmail.com
 *   Organization:  NUS, SoC
 *
 * =====================================================================================
 */

/**************************************************************************
 * This header file describes the searchSortHandler class              
 * It takes in user input and performs sorting based on the tasks already in the system     
 * The class is able to perform sorts based on timings, strings or other attribute properties
 * It is also responsible for displaying tasks according to their indexes
 **************************************************************************/

/*
Expected operation parameters:

display 0

_______Task[0]_______
CG2271 term assignment

Priority: LOW    
Status: UNFINISHED
----------------------
Due by 2359 22/11/2013
----------------------
*/

#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
#include <functional>
#include <ctime>
#include <time.h>
#include "FloatingTask.h"
#include "DeadlineTask.h"
#include "TimedTask.h"

using namespace std;
//@author A0097379H
class sortHandler{

public:
	
	string executeCommand(string, vector<FloatingTask*>);
	sortHandler();

private:
	enum COMMAND_TYPE{
		SORT_TASK, SORT_LOCATION, SORT_PERSON, SORT_DESCRIPTION, SORT_START_TIME, SORT_END_TIME, SORT_START_DEFAULT, SORT_PRIORITY, SORT_FINISHED, SORT_ALL, SORT_INDEX, EXIT, INVALID
	};

	string sortIndex(vector<FloatingTask*>, string);
	string sortAll(vector<FloatingTask*>); //displays all tasks in the system accroding to index
	string sortName(vector<FloatingTask*>);
	string sortLocation(vector<FloatingTask*>);
	string sortPerson(vector<FloatingTask*>);
	string sortDescription(vector<FloatingTask*>);
	string sortStartDate(vector<FloatingTask*>);
	string sortEndDate(vector<FloatingTask*>);
	string sortStartDefault(vector<FloatingTask*>); //sort displaying upcoming timed tasks for displaying on the main menu of the GUI
	string sortPriority(vector<FloatingTask*>);
	string sortFinished(vector<FloatingTask*>);

	COMMAND_TYPE determineCommandType(string);
	static const string MESSAGE_SEARCH_NO_RESULT;
	static const string sortHandler::MESSAGE_INVALID_COMMAND;
};

#endif